<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>兼职招聘系统-企业用户首页</title>
 <link rel="shortcut icon" href="images/copylogo.png">
 <link rel="stylesheet" href="css/reset.css">
 <link rel="stylesheet" href="css/main.css">
 <link rel="stylesheet" href="css/user.css">
 <link rel="stylesheet" href="css/goods.css">
</head>

<body>
	<!-- 头部  -->
	<div class="header_con">
	 	<div class="header">
	 		<div class="welcome fl">欢迎来到兼职招聘系统</div>
	 		<div class="fr">
	         	<div id="n" class="login_info fl"> 欢迎企业用户：<p id="em" style="margin-right: 15px; color:blue">d q</p>
	             </div>
	             <div class="login_btn fl" >
	             	<a href="login.html" id="login">登录</a>
	             	<input type="button" class="dqbtn" id="loginout" value="退出登录" style="display:none" onclick="loginout()">
	                 <span> | </span>
	                 <a href="register_company.html">注册</a>
	             </div>
	         	 <div class="user_link fl">
	         	 	 <span> | </span>
	                 <a href="index_company.html">首页</a>
	                 <span> | </span>
	                 <a href="front/publish_positions.html">发布职位</a>
	                 <span> | </span>
	                 <a href="front/received_resume.html">我收到的简历</a>
	        		 </div> 
	          </div>  
	 	</div>
	 </div>
    
     <!-- 搜素框 -->
     <div class="search_bar clearfix" style="background-color: rgb(226 230 233);height: 370px;width:1550px">
        <img src="images/hello.png" style="margin-top: 10px;">
     </div>
     
    ><!-- 用户中心界面 -->
    <div id="company_info" class="main_con clearfix" style="margin: 5px auto; border-width: 2px; border-style: solid; border-radius: 20px;">
    
    	<!-- 左侧用户菜单栏 -->
		<div class="left_menu_con fl clearfix">
			<h3 style="line-height: 60px;font-size: 25px;">企业用户首页</h3>
			<ul>
				<li style="line-height: 60px;font-size: 20px;"><a href="javascrit:void(0)" target="_blank" class="active" style="color: #8cc11c;">· 企业信息</a></li>
				<li style="line-height: 60px;font-size: 20px;"><a href="front/publish_positions.html" target="_blank">· 发布职位</a></li>
				<li style="line-height: 60px;font-size: 20px;"><a href="front/received_resume.html" target="_blank">· 我收到的简历</a></li>
				<li style="line-height: 60px;font-size: 20px;"><a href="updatePwd_company.html" >· 修改密码</a></li>
			</ul>
		</div>
        
        <!-- 右侧信息展示 -->
        <div class="right_content fr clearfix">
			<!-- 基本信息  -->
            <div class="info_con clearfix">
                <ul class="user_info_list" style="height: 340px">
                	<li style="line-height: 38px;text-indent: 30px;font-size: 18px;color: #64bc09;">公司logo：<span style="padding: 10px;color: black;"><img style="height: 60px;width: 60px;" :src="company.companypic" /></span></li>
                    <li style="line-height: 38px;text-indent: 30px;font-size: 18px;color: #64bc09;">用户昵称：<span style="padding: 10px;color: black;">{{company.nickname}}</span> 公司名称：<span style="padding: 10px;color: black;">{{company.companyname}}</span></li>
                    <li style="line-height: 38px;text-indent: 30px;font-size: 18px;color: #64bc09;">公司类型：<span style="padding: 10px;color: black;">{{company.companytype}}</span></li>
                    <li style="line-height: 38px;text-indent: 30px;font-size: 18px;color: #64bc09;">公司电话：<span style="padding: 10px;color: black;">{{company.tel}}</span>公司邮箱：<span style="padding:10px;color: black;">{{company.email}}</span></li>           
                    <li style="line-height: 38px;text-indent: 30px;font-size: 18px;color: #64bc09;">公司简介：<span style="padding: 10px;color: black;">{{company.companydescr}}</span></li>
                </ul>
            	<h3 class="common_title2">我发布的职位</h3>
                <div class="has_view_list">
                    <ul class="goods_type_list clearfix">
                        <li  v-for="pd in positions">
		                    <a :href="'front/update_positions.html#' + pd.pno" target="_blank"><img :src="pd.companypic"></a>
		                    <h4><a :href="'front/update_positions.html#' + pd.pno" target="_blank">{{pd.pname}}</a></h4>
		                    <div class="operate">
		                    	<span class="prize">月薪：{{pd.price}}</span>
		                        <span class="unit">{{pd.place}}</span>
		                    </div>
                        </li>
                    </ul>
                </div>
                <!-- 分页栏-->
				<div class="pagenation">
					<ul>
						<li><a @click="findBypage(1,pageSize)">首页</a></li>
						<li v-for="tp in totalPage"><a @click="findBypage(tp,pageSize)" :class={"active":tp==pageNo}>{{tp}}</a></li>
						<li><a @click="findBypage(totalPage,pageSize)">尾页</a></li>
					</ul>
				</div>
            </div>
        </div>

    </div>
    
    <!-- 版权所有 -->
	<div class="footer">
    	<div class="foot_link">
    		<a href="#">关于我们</a> <span> | </span>
            <a href="#">联系我们</a> <span> | </span>
            <a href="#">招聘人才</a> <span> | </span>
            <a href="#">友情链接</a> 
    	</div>
    	<p>CopyRight &copy; 2021 沈阳xxxxxx学院  All Rights Reserverd</p>
        <p>电话：131-xxxx9739 </p>
    </div>
    
    <script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui.min.js"></script>
    <script type="text/javascript" src="js/slide.js"></script>
    <script type="text/javascript" src="js/qs.js"></script>
    <script type="text/javascript" src="js/vue.js"></script>
    <script type="text/javascript" src="js/axios.js"></script> 
    <script src="js/websocket.js"></script>
    <script type="text/javascript">
		$(function(){
			//检查登录
			companyCheck();
		})
		
		
		let company_info = new Vue({
			el:"#company_info",
			data:{
				company:[],
				positions:{},
				nickname:"",
			    pageNo : 1,		//当前页数
			    pageSize : 5,	//每页显示几条
			    totalSize : 0,	//总共多少条数据
			    totalPage : 0	//总页数
			},
			methods:{
				findBypage : function(pageNo, pageSize){
					axios.get("company/findBypage", {params:{nickname:this.nickname, pageNo:pageNo, pageSize:pageSize}}).then(result =>{
						this.positions = result.data.positions;
						this.pageNo = pageNo;
						console.log(result.data.positions);
						console.log("当前是第" +this.pageNo+ "页");
					})
				}
			},
			mounted:function(){
				axios.post("../login/getcompanynickname", {params:{}}).then(result =>{
					this.nickname = result.data.nickname;
					
	 				axios.get("../company/finds", {params:{nickname:this.nickname}}).then(result =>{
						console.log(result.data.company);
						if(result.data.company == 0){
							console.log("企业用户名信息查询失败...");
						}else{
							this.company = result.data.company;
						}
					})
							
					axios.get("company/findAllpositions", {params:{nickname:this.nickname}}).then(result =>{
						if(result.data.positions == 0){
							console.log("暂时没有职位信息...");
							$("#dqr").text("没有搜索到职位信息...");
						}else{
							this.totalSize = Object.keys(result.data.positions).length;
							this.totalPage = Math.ceil(this.totalSize / this.pageSize);
							console.log(result.data.positions);
							console.log("找全部,共："+this.totalSize +"条信息---总页数："+ this.totalPage);
						}
					})
						
					axios.get("company/findBypage", {params:{nickname:this.nickname, pageNo:this.pageNo, pageSize:this.pageSize}}).then(result =>{
						this.positions = result.data.positions;
						console.log("找分页,每页"+Object.keys(result.data.positions).length+"条信息--"+result.data.positions);
						console.log("当前第" +this.pageNo+ "页");
					})			
				})				
			}
		})
		
    	//获取用户名
		function getnickname(){
			$.post("login/getcompanynickname", {}, function(data) {
				//用户昵称
				console.log("当前登录的用户名为：" + data.nickname);
				$("#em").text(data.nickname);
				$("#n").css('display', 'flex');
				$("#loginout").css('display', 'inline');
				$("#login").css('display', 'none');
			}, "json");
		}
		
		//下线
		function loginout(){
			$.post("login/companyloginout", {}, function(data) {
				console.log("下线了...");
			}, "text");
			window.location.reload();
		}
		
		function companyCheck(){
				//先发送请求获取登录用户id
				$.get("login/companyCheck", null, function(data){
				if (data.code == 500) {
					console.log("请先登录...");
					$("#em").text("你好！请先登录...");
					$("#n").css('display', 'flex');
					return;
				}
			
				if (data.code == 200) {
					//连上 websocket服务器
					openWebSocket(data.msg);
					getnickname();
				}
			},"json");
		}
    </script>
</body>
</html>
